/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.edu.just.firstjavaapp.l15;


import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 *
 * @author Administrator
 */
public class DataStreamWriteTest02 {
    static final String dataFile = "src/files/io/test02";
    public static void main(String[] args) throws FileNotFoundException, IOException{        
        Object[][] orders ={{"球衣",212.32,10},
                       {"球鞋",234.56,12},
                       {"篮球",88.12,23} } ;     
        DataOutputStream out = null;    
        
        try {
            out = new DataOutputStream(new
            BufferedOutputStream(new FileOutputStream(dataFile)));  //wrapper
            for(Object[] order :orders){
                out.writeUTF((String)order[0]);
                out.writeDouble((Double)order[1]);         
                out.writeInt((int)order[2]);                
                
            }
        } finally {
            out.close();
        }        
    }
}
